require 'rexml/document'
include REXML

nameCode = ARGV[0]
vorn = ARGV[1]
raise RuntimeError.new('Please provide the name code in first argument') if nameCode == nil 
raise RuntimeError.new('2nd argument must be "value" or "name"') if !['value', 'name'].include? vorn

root = Document.new(File.open("OpenTravel_CodeList_20090615.xml")).root

h = 
{
		"value" => ["//OTA_CodeTable[@NameCode='#{nameCode}']/Codes/Code", "Value"], 
		"name" => ["//OTA_CodeTable[@NameCode='#{nameCode}']/Codes/Code/CodeContents/CodeContent", "Name"]
}


xarray = h[vorn]

root.get_elements(xarray[0]).each do |e|
	puts e.attributes[xarray[1]]
end


